<?php


namespace app\api\model;


use iflow\Response;
use think\Model;

class ApiListModel extends Model
{
    protected $table = "api_list_table";


    public function getApiList(int $page, string $keyword = ''): Response
    {
        $query = $this;
        if ($keyword !== '') {
            $query = $query -> whereLike('api_name', "%${keyword}%");
        }

        $query = $query -> paginate([
            'page' => $page
        ]);

        if ($query -> items()) {
            return message() -> success('ok', $query -> items(), [
                'total' => $query -> total(),
                'page' => $query -> lastPage()
            ]);
        }
        return message() -> nodata();
    }
}